package com.ruoyi.system.service.impl;


import com.masiyi.ffmpeg.template.FFmpegTemplate;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.service.FFmpegService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.io.IOException;

@Service
public class FFmpegServiceImpl implements FFmpegService {



    @Override
    public AjaxResult pushVideoToRtmp(String videoPath, String rtmpUrl) {
       FFmpegTemplate ffmpegTemplate = new FFmpegTemplate();
        String cleannedPath=videoPath.replace("/profile/upload","");
        String profile=RuoYiConfig.getUploadPath();

        videoPath=profile+cleannedPath;
        System.out.println(videoPath);

//        try {
//        ffmpegTemplate.execute("ffmpeg -re -i " + videoPath + " -vcodec libx264 -acodec aac -c copy -flvflags no_duration_filesize -f flv  -safe 0 " + rtmpUrl);
//            System.out.println(rtmpUrl);
//            System.out.println(videoPath);
//       } catch (IOException | InterruptedException e) {
//            throw new RuntimeException(e);
//        }

      return AjaxResult.success();
    }
}
